from flask import Flask,render_template
import sqlite3

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')

@app.route('/index')
def home():
    return render_template('index.html')

@app.route('/movie')
def movie():
    movie_list = []
    con = sqlite3.connect('movie.db')
    cur = con.cursor()
    sql = "select * from movietop250"
    data = cur.execute(sql)
    for item in data:
        movie_list.append(item)
    cur.close()
    con.close()

    return render_template('movie.html',movies = movie_list)

@app.route('/score')
def score():
    score = []
    num = []
    con = sqlite3.connect('movie.db')
    cur = con.cursor()
    sql = "select pingfen,count(pingfen) from movietop250 group by pingfen"
    data = cur.execute(sql)
    for item in data:
        score.append(item[0])
        num.append(item[1])
    cur.close()
    con.close()
    return render_template('score.html',score = score,num = num)

@app.route('/word')
def word():
    return render_template('word.html')

@app.route('/team')
def team():
    return render_template('team.html')


if __name__ == '__main__':
    app.run(debug=True,port=8898)
